﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.tobyfreeman.utils {
    import flash.display.*;
    import flash.geom.*;

    public class Colors {

        public function Colors(){
            super();
            throw (new Error("ERROR com.tobyfreeman.utils.Colors constructor: Class never intended to be instantiated"));
        }
        public static function clearRGBA(obj:DisplayObject):void{
            obj.transform.colorTransform = new ColorTransform();
        }
        public static function setRGB(obj:DisplayObject, rgb:uint):void{
            var CT:ColorTransform = obj.transform.colorTransform;
            CT.color = rgb;
            obj.transform.colorTransform = CT;
        }
        public static function tintRGB(obj:DisplayObject, rgb:uint, percent:Number):void{
            percent = (Math.max(0, Math.min(100, percent)) / 100);
            var CT:ColorTransform = obj.transform.colorTransform;
            CT.redOffset = (CT.redOffset + ((rgb >> 16) * percent));
            CT.greenOffset = (CT.greenOffset + (((rgb >> 8) & 0xFF) * percent));
            CT.blueOffset = (CT.blueOffset + ((rgb & 0xFF) * percent));
            percent = (1 - percent);
            CT.redMultiplier = percent;
            CT.greenMultiplier = percent;
            CT.blueMultiplier = percent;
            obj.transform.colorTransform = CT;
        }
        public static function splitRGB(rgb:uint):Array{
            return ([(rgb >> 16), ((rgb >> 8) & 0xFF), (rgb & 0xFF)]);
        }
        public static function setRGBA(obj:DisplayObject, rgb:uint, a:uint):void{
            var CT:ColorTransform = new ColorTransform();
            CT.color = rgb;
            CT.alphaMultiplier = 0;
            CT.alphaOffset = a;
            obj.transform.colorTransform = CT;
        }

    }
}//package com.tobyfreeman.utils 
